import {messages} from "share/common";
import React from "react";

export default {
  SQ003: {
    /**
     * 申请单行
     * @returns {[{dataIndex: string, editable: boolean, defaultValue: string, width: number, needFixed: boolean, title: string},{isRequired: boolean, dataIndex: string, editable: boolean, trueTitle: string, width: number, inputType: string, needFixed: boolean, title: JSX.Element},{isReadOnly: boolean, dataIndex: string, editable: boolean, width: number, inputType: string, needFixed: boolean, title: string},{isRequired: boolean, dataIndex: string, editable: boolean, trueTitle: string, width: number, inputType: string, needFixed: boolean, title: JSX.Element},{isReadOnly: boolean, dataIndex: string, editable: boolean, width: number, inputType: string, needFixed: boolean, title: string},null,null]}
     */
    request: () => {
      let columns = [
        {
          title: messages('request.key772'/*礼品*/),
          dataIndex: 'formType',
          width: 70,
          editable: false,
          defaultValue: messages('request.key785'/*礼品卡*/),
          needFixed: true
        }, {
          title: <div className="red-with-star">{messages('request.key774'/*礼品类型*/)}</div>,
          dataIndex: 'type',
          width: 170,
          editable: true,
          isRequired: true,
          inputType: 'select',
          trueTitle: messages('request.key774'/*礼品类型*/),
          needFixed: true
        }, {
          title: messages('request.key786'/*单张面值*/),
          dataIndex: 'unitPrice',
          width: 115,
          editable: true,
          isReadOnly: true,
          inputType: 'inputNumber',
          needFixed: true
        }, {
          title: <div className="red-with-star">{messages('request.key787'/*申请数量*/)}</div>,
          dataIndex: 'applyQuantity',
          width: 115,
          editable: true,
          isRequired: true,
          inputType: 'inputNumber',
          trueTitle: messages('request.key787'/*申请数量*/),
          needFixed: true
        }, {
          title: messages('request.key788'/*领用数量*/),
          dataIndex: 'receiveQuantity',
          width: 115,
          editable: true,
          isReadOnly: true,
          // isRequired: true,
          inputType: 'inputNumber',
          needFixed: true
        }, {
          title: messages('request.key778'/*金额*/),
          dataIndex: 'amount',
          width: 115,
          editable: true,
          isReadOnly: true,
          inputType: 'inputNumber'
        },
      ]
      // TODO 你可以在这里做点什么
      return columns
    },
    /**
     * 接收人行
     * @returns {*[]}
     */
    receive: () => {
      let columns = [
        {
          title: <div className="red-with-star">所属机构/公司名称</div>,
          dataIndex: 'organization',
          width: '15%',
          editable: true,
          isRequired: true,
          inputType: 'input',
          trueTitle: '所属机构/公司名称'
        }, {
          title: <div className="red-with-star">职位</div>,
          dataIndex: 'position',
          width: '15%',
          editable: true,
          isRequired: true,
          inputType: 'input',
          trueTitle: '职位'
        }, {
          title: <div className="red-with-star">名称</div>,
          dataIndex: 'name',
          width: '15%',
          editable: true,
          isRequired: true,
          inputType: 'input',
          trueTitle: '名称'
        }, {
          title: <div className="red-with-star">{"手机号码"}</div>,
          dataIndex: 'contactInformation',
          width: 130,
          editable: true,
          isRequired: true,
          trueTitle: "手机号码"
        }, {
          title: messages('request.key772'/*礼品*/),
          dataIndex: 'gift',
          width: 70,
          editable: false,
          isRequired: true,
          defaultValue: messages('request.key785'/*礼品卡*/),
        }, {
          title: <div className="red-with-star">{messages('request.key774'/*礼品类型*/)}</div>,
          dataIndex: 'giftType',
          width: 170,
          editable: true,
          isRequired: true,
          inputType: 'select',
          trueTitle: messages('request.key774'/*礼品类型*/),
        }, {
          title: <div className="red-with-star">数量</div>,
          dataIndex: 'quantity',
          width: '15%',
          editable: true,
          isRequired: true,
          inputType: 'inputNumber',
          trueTitle: '数量'
        }, {
          title: <div className="red-with-star">金额</div>,
          dataIndex: 'amount',
          width: '15%',
          editable: true,
          isRequired: true,
          inputType: 'inputNumber',
          trueTitle: '金额'
        }, 
        // {
        //   title: <div className="red-with-star">是否有政府人员参与</div>,
        //   dataIndex: 'governmentName',
        //   width: '15%',
        //   editable: true,
        //   isRequired: true,
        //   inputType: 'chooser',
        //   trueTitle: '是否有政府人员参与'
        // }, {
        //   title: <div className="red-with-star">12个月内同一人超过2次</div>,
        //   dataIndex: 'isTwice',
        //   width: '15%',
        //   editable: true,
        //   isRequired: false,
        //   inputType: 'switch',
        //   trueTitle: '12个月内同一人超过2次'
        // }, {
        //   title: '过去12个月内同一人超过2次的理由说明',
        //   dataIndex: 'remark',
        //   width: '15%',
        //   editable: false,
        //   isRequired: true,
        //   inputType: 'input',
        //   trueTitle: '过去12个月内同一人超过2次的理由说明'
        // }, 
        {
          title: '发放状态',
          dataIndex: 'distributionStatus',
          width: 130,
          editable: false,
          trueTitle: '发货状态'
        }, {
          title: '行号',
          dataIndex: 'lineNo',
          // width: 70,
          editable: false,
        },
      ]
      return columns
    }
  },
  default: {
    request: (vm) => {
      const {info} = vm.state
      let columns = []
      const columns1 = [{
        title: messages('request.key772'/*礼品*/),
        dataIndex: 'formType',
        width: 70,
        editable: false,
        defaultValue: messages('request.key785'/*礼品卡*/),
        needFixed: true
      }, {
        title: <div className="red-with-star">{messages('request.key774'/*礼品类型*/)}</div>,
        dataIndex: 'type',
        width: 170,
        editable: true,
        isRequired: true,
        inputType: 'select',
        trueTitle: messages('request.key774'/*礼品类型*/),
        needFixed: true
      }, {
        title: messages('request.key786'/*单张面值*/),
        dataIndex: 'unitPrice',
        width: 115,
        editable: true,
        isReadOnly: true,
        inputType: 'inputNumber',
        needFixed: true
      }, {
        title: <div className="red-with-star">{messages('request.key787'/*申请数量*/)}</div>,
        dataIndex: 'applyQuantity',
        width: 115,
        editable: true,
        isRequired: true,
        inputType: 'inputNumber',
        trueTitle: messages('request.key787'/*申请数量*/),
        needFixed: true
      }, {
        title: messages('request.key788'/*领用数量*/),
        dataIndex: 'receiveQuantity',
        width: 115,
        editable: true,
        isReadOnly: true,
        // isRequired: true,
        inputType: 'inputNumber',
        needFixed: true
      }, {
        title: messages('request.key778'/*金额*/),
        dataIndex: 'amount',
        width: 115,
        editable: true,
        isReadOnly: true,
        inputType: 'inputNumber'
      }, {
        title: <div className="red-with-star">{messages('request.key789'/*领用人*/)}</div>,
        dataIndex: 'employeeName',
        width: 110,
        editable: true,
        isRequired: true,
        inputType: 'chooser',
        trueTitle: messages('request.key789'/*领用人*/)
      }, {
        title: <div className="red-with-star">{messages('request.key790'/*收货地址*/)}</div>,
        dataIndex: 'address',
        width: 140,
        editable: true,
        isRequired: true,
        inputType: 'select',
        trueTitle: messages('request.key790'/*收货地址*/)
      }, {
        title: <div className="red-with-star">{messages('request.key807'/*联系方式*/)}</div>,
        dataIndex: 'contactWay',
        width: 130,
        editable: true,
        isRequired: true,
        trueTitle: messages('request.key807'/*联系方式*/)
      }]

      const columns2 = [{
        title: messages('request.key791'/*券号信息*/),
        dataIndex: 'cardNumber',
        width: 150,
        editable: false,
        isRequired: true
      }, {
        title: messages('request.key792'/*发放方式*/),
        dataIndex: 'sendWayText',
        width: 100,
        editable: false,
        isRequired: true,
        inputType: 'select'
      }, {
        title: messages('request.key793'/*快递信息*/),
        dataIndex: 'deliveryInfo',
        width: 100,
        editable: false,
        isRequired: true
      }, {
        title: messages('request.key794'/*联系人*/),
        dataIndex: 'link',
        width: 100,
        editable: false,
        isRequired: true
      }, {
        title: messages('request.key795'/*电话*/),
        dataIndex: 'phone',
        width: 130,
        editable: false,
        isRequired: true
      }, {
        title: messages('request.key796'/*附件*/),
        dataIndex: 'appendix',
        width: 200,
        editable: false,
        inputType: 'upload'
      }]

      let isEditFlag = ['10011000', '10011001', '10011002'].includes(`${info.status}${info.rejectType}`)
      const isDeleteBtnFlag = isEditFlag && ['SQ021', 'SQ022', 'SQ023'].includes(info.formCode)
      if (isDeleteBtnFlag) {
        columns1.map(item => {
          item.editable = false
          if (item.dataIndex === 'receiveQuantity' || item.dataIndex === 'amount') {
            item.editable = true
            if (item.dataIndex === 'amount') {
              item.isReadOnly = true
            } else {
              item.isReadOnly = false
            }
          }
          item.title = item.trueTitle ? item.trueTitle : item.title
          if (item.dataIndex === 'receiveQuantity') {
            // if (['SQ021', 'SQ022', 'SQ023'].includes(info.formCode)) {
            //   item.title = messages('request.key788'/*领用数量*/)
            // } else {
            item.title = <div className="red-with-star">{messages('request.key788'/*领用数量*/)}</div>
            item.trueTitle = messages('request.key788'/*领用数量*/)
            item.isRequired = true
            // }
          }
        })
        columns2.map(item => {
          item.editable = true
          if (['cardNumber', 'sendWayText', 'link', 'phone'].includes(item.dataIndex)) {
            // if (['SQ021', 'SQ022', 'SQ023'].includes(info.formCode)) {
            //   item.isRequired = false;
            // } else {
            item.trueTitle = item.title;
            item.title = <div className="red-with-star">{item.trueTitle}</div>
            // }
          }
        })
      }
      columns = [...columns1, ...columns2]

      return columns
    },
    receive: (vm) => {
      const {info} = vm.state
      const columns1 = [{
        title: <div className="red-with-star">所属机构/公司名称</div>,
        dataIndex: 'organization',
        width: '15%',
        editable: true,
        isRequired: true,
        inputType: 'input',
        trueTitle: '所属机构/公司名称'
      }, {
        title: <div className="red-with-star">职位</div>,
        dataIndex: 'position',
        width: '15%',
        editable: true,
        isRequired: true,
        inputType: 'input',
        trueTitle: '职位'
      }, {
        title: <div className="red-with-star">名称</div>,
        dataIndex: 'name',
        width: '15%',
        editable: true,
        isRequired: true,
        inputType: 'input',
        trueTitle: '名称'
      }, {
        title: <div className="red-with-star">金额</div>,
        dataIndex: 'amount',
        width: '15%',
        editable: true,
        isRequired: true,
        inputType: 'inputNumber',
        trueTitle: '金额'
      }]
      const columns2 = [{
        title: <div className="red-with-star">是否有政府人员参与</div>,
        dataIndex: 'governmentName',
        width: '15%',
        editable: true,
        isRequired: true,
        inputType: 'chooser',
        trueTitle: '是否有政府人员参与'
      }, {
        title: <div className="red-with-star">12个月内同一人超过2次</div>,
        dataIndex: 'isTwice',
        width: '15%',
        editable: true,
        isRequired: false,
        inputType: 'switch',
        trueTitle: '12个月内同一人超过2次'
      }, {
        title: '过去12个月内同一人超过2次的理由说明',
        dataIndex: 'remark',
        width: '15%',
        editable: false,
        isRequired: true,
        inputType: 'input',
        trueTitle: '过去12个月内同一人超过2次的理由说明'
      }]
      let columns = columns1
      if (info.formCode !== 'SQ004' && info.formCode !== 'SQ023') {
        columns = [
          ...columns,
          ...columns2
        ]
      }
      return columns
    }
  }
}
